Built-in Extensions
Using extensions may drastically reduce your When event's performance. Use when it's really needed.
Extensions to add onto the library and assist with utilizing When.
local When = game:GetService("ReplicatedStorage").When
local when = require(when)
when.extend(
when.Extensions["Interoperable"] -- Example of loading Interoperable
)
Extensions of When should be loaded in the main script and waited for in the other script
Interoperable
Interoperable is an extension that allows you to replace BindableEvents with When by introducing background processes and attaching functions to the When library so you can access it without manually requiring it and make it work with When. It is still script interface and follows the kind of HTTPService-DatastoreService-ish syntax.
Type | ID |
---|---|
Core | interoperable |
.publish()
when.publish(
event : WhenEvent,
key? : string || number
)
Publish/overwrite the event into the pool where it can be acccessed through keys.
.retrieve()
⚠️ Notice: Using .retrieve() alone can be unstable. It is advised you check out .retrieveAsync() instead.
when.retrieve(
key? : string || number
)
Retrieve the event from the pool by a key.
.retrieveAsync()
when.retrieveAsync(
key? : string || number
)
If available, it retrieve the event from the pool by a key, else it yields until an event is returned.
.unlist()
when.unlist(
key? : string || number
)
Unlists the event with the key off of the pool.
Internal
Internal is an extension that acts as a dependency and framework for developers to access the event itself inside of the connection. It is supposed to be an out-of-view extension, but developers can utilize it as a a standalone to their benefit. Internal replaces the pure When event process with a more expansive structure.
Type | ID |
---|---|
Core | internal |
._list()
when._list(
arg,
usage? : string
)
Embeds a single argument on every connection for each event. Useful for making a built-in function within the connection.
Suspend
Suspend embeds a built-in function within a connection of an event that allows you to disconnect the event right from the inside.
Type | ID | Dependencies |
---|---|---|
Core | suspend | internal |
.suspend()
event:Connect(
fn(
suspend? : function, -- Can be named, else set to nil
...
),
key? : string || number
)
Embeds a single argument on every connection for each event. Useful for making a built-in function within the connection.
Terminate
Terminate embeds a built-in function within a connection of an event that allows you to destroy the event right from the inside.
Type | ID | Dependencies |
---|---|---|
Core | terminate | internal |
.terminate()
event:Connect(
fn(
terminate? : function, -- Can be named, else set to nil
...
),
key? : string || number
)
Embeds a single argument on every connection for each event. Useful for making a built-in function within the connection.